package com.kuang.demo.controller;

import com.kuang.demo.bean.BaseRespVo;
import com.kuang.demo.bean.acgBeanVo.BaseData;
import com.kuang.demo.bean.acgBeanVo.TotalData;
import com.kuang.demo.bean.acgBeanVo.UserAddressVo;
import com.kuang.demo.bo.acg.*;
import com.kuang.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ACG
 * @date 2020-10-31 15:38
 */
@RestController
//@RequestMapping("admin/auth")
@RequestMapping("admin")
public class UserController {

    @Autowired
    UserService userService;


    //http://182.92.235.201:8083/admin/dashboard
    @RequestMapping("/dashboard")
    public BaseRespVo dashboardControl(){
        TotalData totalData = userService.dashboardControl();
        return BaseRespVo.ok(totalData);
    }
    @RequestMapping("/user/list")
    public BaseRespVo userControl(UserList userList){
        System.out.println(userList.getUsername()+userList.getMobile());
        BaseData baseData = userService.userControl(userList.getPage(),
                userList.getLimit(), userList.getSort(), userList.getOrder(),
                userList.getUsername(),userList.getMobile());
        return BaseRespVo.ok(baseData);
    }



    //http://182.92.235.201:8083/admin/address/list?page=1&limit=20&sort=add_time&order=desc
    //http://182.92.235.201:8083/admin/address/list?page=1&limit=20&userId=1
    // &sort=add_time&order=desc
//http://182.92.235.201:8083/admin/address/list?page=1&
// limit=20&name=%E5%B0%8F&userId=1&sort=add_time&order=desc
    @RequestMapping("/address/list")
    public BaseRespVo addressControl(AddressList addressList){
        UserAddressVo userAddressVo = userService.addressControl(addressList.getPage(), addressList.getLimit(),
                addressList.getSort(), addressList.getOrder(),addressList.getName(),addressList.getUserId());

        return BaseRespVo.ok(userAddressVo);
    }

    //http://182.92.235.201:8083/admin/collect/list?page=1&limit=20&sort=add_time&order=desc
    //admin/collect/list?page=1&limit=20&userId=3&valueId=10&sort=add_time&order=desc
    @RequestMapping("/collect/list")
    public BaseRespVo collectControl(CollectList collectList){
        BaseData baseData =  userService.collectControl(collectList.getPage(),collectList.getLimit(),collectList.getSort(),collectList.getOrder(),
                collectList.getUserId(),collectList.getValueId());
        return BaseRespVo.ok(baseData);
    }


    //http://182.92.235.201:8083
    // /admin/footprint/list?page=1&limit=20&userId=1&goodsId=11&sort=add_time&order=desc
    @RequestMapping("/footprint/list")
    public BaseRespVo footprintControl(FootpringList footpringList){
        BaseData baseData =  userService.footprintControl(footpringList.getPage(),footpringList.getLimit(),
                footpringList.getUserId(),footpringList.getGoodsId(),footpringList.getSort(),
                footpringList.getOrder());
        return BaseRespVo.ok(baseData);
    }

    // http://182.92.235.201:8083/admin/history/list?
    // page=1&limit=20&userId=123&keyword=123&sort=add_time&order=desc

    @RequestMapping("/history/list")
    public BaseRespVo historyControl(HistoryList historyList){
        BaseData baseData =  userService.historyControl(historyList.getPage(),historyList.getLimit(),
                historyList.getUserId(),historyList.getKeyword(),
                historyList.getSort(),historyList.getOrder());
        return BaseRespVo.ok(baseData);
    }

    //http://182.92.235.201:8083/admin/feedback/list?page=1&limit=20&sort=add_time&order=desc
    //http://182.92.235.201:8083/admin/feedback/list?page=1&limit=20&username=1&sort=add_time&order=desc&id=1
    @RequestMapping("/feedback/list")
    public BaseRespVo feedbackControl(FeedbackList feedbackList){
        Feedback feedback =   userService.feedbackControl(feedbackList.getPage(),feedbackList.getLimit(),
                feedbackList.getUsername(),feedbackList.getSort(),feedbackList.getOrder(),feedbackList.getId());
        return BaseRespVo.ok(feedback);
    }

}
